c08d35ebe1a7eae45d532130786efa396b7f9cd4,bukkit-utils/src/main/java/dk/lockfuglsang/minecraft/command/DocumentCommand.java,DocumentCommand,writePlainText,#CommandSender#,48
Before Change
private boolean writePlainText(CommandSender sender) {
File docFile = new File(plugin.getDataFolder(), getName() + ".txt");
try (FileOutputStream fos = new FileOutputStream(docFile);PrintStream ps = new PrintStream(fos, true, "UTF-8")) {
PlainTextCommandVisitor visitor = new PlainTextCommandVisitor();
List<String> commands = new ArrayList<>(plugin.getDescription().getCommands().keySet());
Collections.sort(commands);
for (String cmd : commands) {
PluginCommand pluginCommand = plugin.getCommand(cmd);
if (pluginCommand.getExecutor() instanceof Command) {
((Command) pluginCommand.getExecutor()).accept(visitor);
}
// TODO: 03/11/2015 - R4zorax: else?
}
visitor.writeTo(ps);
sender.sendMessage(tr("Wrote documentation to {0}", docFile));
return true;
} catch (IOException e) {
After Change
return false;
}
private boolean writeToFile(CommandSender sender, DocumentWriter visitor, String filename) {
List<String> commands = new ArrayList<>(plugin.getDescription().getCommands().keySet());
Collections.sort(commands);
for (String cmd : commands) {
PluginCommand pluginCommand = plugin.getCommand(cmd);
if (pluginCommand.getExecutor() instanceof Command) {
((Command) pluginCommand.getExecutor()).accept(visitor);
}
}
File docFile = new File(plugin.getDataFolder(), filename);
try (FileOutputStream fos = new FileOutputStream(docFile);
PrintStream ps = new PrintStream(fos, true, "UTF-8"))
{
visitor.writeTo(ps);
sender.sendMessage(tr("Wrote documentation to {0}", docFile));
return true;
} catch (IOException e) {